package com.hy.mydesktop.client.component.factory;

import com.extjs.gxt.ui.client.widget.layout.FlowData;
import com.hy.mydesktop.client.component.meta.FlowDataModelEnum;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;

/**
 * 
 * 
 * <ul>
 * <li>开发作者：冬超</li>
 * <li>设计日期：2010-8-31；时间：下午03:28:08</li>
 * <li>类型名称：FlowDataFactory</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class FlowDataFactory {
	public static FlowData createFlowData(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		return configureFlowData(gxtComponentMetaNodeModel);

	}

	private static FlowData configureFlowData(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		FlowData flowData = null;
		if (gxtComponentMetaNodeModel.get(FlowDataModelEnum.MARGIN.name()
				.toLowerCase()) != null) {

			Integer margin = (Integer) gxtComponentMetaNodeModel
					.get(FlowDataModelEnum.MARGIN.name().toLowerCase());
			flowData = new FlowData(margin);

		} 
		if (gxtComponentMetaNodeModel.get(FlowDataModelEnum.BOTTOM
				.name().toLowerCase()) != null
				&& gxtComponentMetaNodeModel.get(FlowDataModelEnum.LEFT
						.name().toLowerCase()) != null
				&& gxtComponentMetaNodeModel.get(FlowDataModelEnum.RIGHT
						.name().toLowerCase()) != null
				&& gxtComponentMetaNodeModel.get(FlowDataModelEnum.TOP
						.name().toLowerCase()) != null) {

			Integer bottom = (Integer) gxtComponentMetaNodeModel
					.get(FlowDataModelEnum.BOTTOM.name().toLowerCase());
			
			Integer left = (Integer) gxtComponentMetaNodeModel
			.get(FlowDataModelEnum.LEFT.name().toLowerCase());
			
			Integer right = (Integer) gxtComponentMetaNodeModel
			.get(FlowDataModelEnum.RIGHT.name().toLowerCase());
			
			Integer top = (Integer) gxtComponentMetaNodeModel
			.get(FlowDataModelEnum.TOP.name().toLowerCase());
			flowData = new FlowData(top, right, bottom, left);
		}
		return flowData;
	}

}
